#include "EPSG/Engine.h"

std::vector<EPSG::Engine*> EPSG::Engine::s_engines;

EPSG::Engine::Engine()
{
	s_engines.push_back( this );
}

bool EPSG::Engine::execute( unsigned char key, int x, int y )
{
	if( s_engines.empty() )
		return false;

	bool used = false;
	std::vector<EPSG::Engine*>::iterator i;
	for( i = s_engines.begin(); i != s_engines.end(); i++ )
		if( (*i)->apply( key, x, y ) )
			used = true;

	return used;
}

bool EPSG::Engine::execute( int button, int state, int x, int y )
{
	if( s_engines.empty() )
		return false;

	bool used = false;
	std::vector<EPSG::Engine*>::iterator i;
	for( i = s_engines.begin(); i != s_engines.end(); i++ )
		if( (*i)->apply( button, state, x, y ) )
			used = true;

	return used;
}

bool EPSG::Engine::execute( int x, int y )
{
	if( s_engines.empty() )
		return false;

	bool used = false;
	std::vector<EPSG::Engine*>::iterator i;
	for( i = s_engines.begin(); i != s_engines.end(); i++ )
		if( (*i)->apply( x, y ) )
			used = true;

	return used;
}